package com.compress.util;

import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.Arrays;

public class FileUtil {
	/**
	 * 读取指定路径的文件内容
	 * @param filePath
	 * @return
	 * @throws Exception
	 */
	public static String copy(String filePath) throws Exception {

		try (InputStreamReader ir = new InputStreamReader(new FileInputStream(filePath), "utf-8");) {
			StringBuffer sb = new StringBuffer();
			char[] cache = new char[512];
			int pos = 0;
			while ((pos = ir.read(cache)) != -1) {
				sb.append(Arrays.copyOf(cache, pos));
			}
			return sb.toString();
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}

	}
}
